package org.jianfa.learn.dubbo.filter;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.LinkedList;
import java.util.List;

public class DataBuffer {

    private String startTime;
    private String endTime;
    private List<Double> buf;

    public DataBuffer() {
        buf = new LinkedList<>();
    }

    public void startCollection() {
        buf = new LinkedList<>();
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss SS");
        Date date = new Date();
        startTime = sdf.format(date);
    }

    public void endCollection() {
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss SS");
        Date date = new Date();
        endTime = sdf.format(date);
    }

    public void recoredResponseTime(double responseTime) {
        buf.add(responseTime);
    }

    public String getStartTime() {
        return startTime;
    }

    public String getEndTime() {
        return endTime;
    }

    public List<Double> getBuf() {
        return buf;
    }
}
